//
//  BasicWhiteViewController.m
//  Experss
//
//  Created by wmwMAC on 17/8/3.
//  Copyright © 2017年 嗯，大葱. All rights reserved.
//

#import "BasicWhiteViewController.h"

@interface BasicWhiteViewController ()

@end

@implementation BasicWhiteViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    //    if (self.backBarTextIsBack) {
    //
    //        self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
    //    }
    
    
    //把navigationbar上的title字体颜色设置为白色
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor blackColor]}];
    //返回箭头颜色
    [self.navigationController.navigationBar setTintColor:[UIColor lightGrayColor]];
    //设置导航栏背景色为紫色
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new]forBarPosition:(UIBarPositionAny) barMetrics:(UIBarMetricsDefault)];
    self.navigationController.navigationBar.translucent = NO;
    
    
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"all_fanhui2"] style:(UIBarButtonItemStyleDone) target:self action:@selector(backAction)];
//    backItem.tintColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem = backItem;
    
    
}
-(void)backAction {
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - removeKeyboardNotification
- (void)removeKeyboardNotification
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidShowNotification object:nil];
}
#pragma mark - addNotifications

#pragma mark - UIKeyboard - Notification
-(void)keyboardDidShow:(NSNotification *)aNotification
{
    
}
- (void)keyboardWillShow:(NSNotification *)aNotification
{
    NSDictionary *userInfo = [aNotification userInfo];
    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [aValue CGRectValue];
    self.keyboarHeight = keyboardRect.size.height;
    
}
- (void)keyboardWillHide:(NSNotification *)aNotification
{
    self.keyboarHeight = 0;
}
-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];
    self.navigationController.navigationBar.translucent = NO;
    //把navigationbar上的title字体颜色设置为黑色
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor blackColor]}];
    [self.navigationController.navigationBar setTintColor:[UIColor lightGrayColor]];
    //设置导航栏背景色为白色
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new]forBarPosition:(UIBarPositionAny) barMetrics:(UIBarMetricsDefault)];
    
    
    //设置状态栏
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}

-(void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
    //把navigationbar上的title字体颜色设置为黑色
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor blackColor]}];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    //设置导航栏背景色为紫色
    [self.navigationController.navigationBar setBackgroundImage:nil forBarPosition:(UIBarPositionAny) barMetrics:(UIBarMetricsDefault)];
    self.navigationController.navigationBar.translucent = YES;
    
}
@end
